package models

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

func init() {
	// 注册数据库
	aliasName := beego.AppConfig.String("alias_name")
	dbType := beego.AppConfig.String("db_type")
	dataSource := fmt.Sprintf(
		"%s:%s@tcp(%s:%s)/%s?charset=utf8",
		beego.AppConfig.String("db_user"),
		beego.AppConfig.String("db_pass"),
		beego.AppConfig.String("db_host"),
		beego.AppConfig.String("db_part"),
		beego.AppConfig.String("db_name"),
	)

	orm.RegisterDataBase(aliasName, dbType, dataSource)
	orm.Debug = false
}
